package com.erp.domain;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.erp.dto.Examine;

@Entity
@Table(name = "t_examine")
public class TExamine implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	private Integer id;
	private TUser tAuditor;// 审批人
	private Date examineTime;// 审批时间
	private Integer opinion;// 审批意见
	private String taskId;// 任务编号
	private String note;// 审批备注
	private TApply tApply;// 对应的申请表

	public TExamine() {
	}

	public TExamine(Examine examine) {
		this.id = examine.getId();
		this.tAuditor = new TUser(examine.getAuditor());
		this.examineTime = examine.getExamineTime();
		this.opinion = examine.getOpinion();
		this.taskId = examine.getTaskId();
		this.note = examine.getNote();
		this.tApply = new TApply(examine.getApply());
	}

	@Id
	@GeneratedValue
	@Column(name = "id")
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * tAuditor属性，本类与TUser是多对一单向关系
	 * 
	 * @return
	 */
	@ManyToOne
	@JoinColumn(name = "auditor_id")
	public TUser gettAuditor() {
		return tAuditor;
	}

	public void settAuditor(TUser tAuditor) {
		this.tAuditor = tAuditor;
	}

	@Column(name = "examinetime")
	public Date getExamineTime() {
		return examineTime;
	}

	public void setExamineTime(Date examineTime) {
		this.examineTime = examineTime;
	}

	@Column(name = "opinion")
	public Integer getOpinion() {
		return opinion;
	}

	/**
	 * 0表示待查看，1表示处理中，2表示不通过，3表示通过
	 * 
	 * @param opinion
	 */
	public void setOpinion(Integer opinion) {
		this.opinion = opinion;
	}

	@Column(name = "taskId")
	public String getTaskId() {
		return taskId;
	}

	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}

	@Column(name = "note")
	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	/**
	 * tApply属性，本类与TApply是多对一双向关系
	 * 
	 * @return
	 */
	@ManyToOne(cascade = { CascadeType.REFRESH, CascadeType.PERSIST,
			CascadeType.MERGE })
	@JoinColumn(name = "apply_id")
	public TApply gettApply() {
		return tApply;
	}

	public void settApply(TApply tApply) {
		this.tApply = tApply;
	}

}
